|
|
|
|
|
|
|
Figure T5- 7:
Passing strings as parameters |
|
|
|
|
|
|
|
|
Calling the Unicode Entry Point |
|
|
|
|
|
|
|
|
Regardless of whether you use ByVal or ByRef, Visual Basic passes a temporary ANSI string to the API functions when using the Declare statement. But what if you want to pass a pointer to a Unicode string (a pointer to a BSTR) or a pointer to a dynamic string variable that refers to a Unicode string? You might want to do this if you need to call the Unicode entry point of a function or if you are calling an OLE function that requires a Unicode string. |
|
|
|
|
|
|
|
|
There are two ways to accomplish this. |
|
|
|
|
|
|
|
|
Create a type library where you actually specify the BSTR data type. |
|
|
|
|
|
|
|
|
Pass the address using a Long parameter as you saw earlier in the RtlMoveMemory examples. |
|
|
|
|
|
|
|
|
For example, consider this declaration for the Unicode entry point for the SetWindowText function: |
|
|
|
|
|
|
|
|
Declare Function SetWindowText Lib "user32" Alias "SetWindowTextW" _
(ByVal hwnd As Long, ByVal lpString As Long) As Long |
|
|
|
|
|